package com.ncmmall.domain.business.order.groupbooking;

import com.fasterxml.jackson.annotation.JsonBackReference;
import com.ncmmall.domain.business.goods.sku.GoodsSku;
import com.ncmmall.domain.security.user.WebUser;
import com.google.common.collect.Lists;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import java.sql.Timestamp;
import java.util.List;
import java.util.Map;

/**
 * 拼团
 *
 * @author linxs
 * @date 2020-02-28 18:20
 */
@Entity
@Table(name = "mall_groupbooking")
@Access(AccessType.FIELD)
@Getter
@Setter
public class GroupBooking {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private long id;

    /**
     * 所属商家
     */
    @JsonBackReference
    @OneToOne
    private WebUser merchant;

    /**
     * 团长
     */
    @JsonBackReference
    @OneToOne
    private WebUser member;

    /**
     * 拼团编号
     */
    private String groupBookingNo;

    /**
     * 开团时间
     */
    private Timestamp createTime;

    /**
     * 拼团结束时间
     */
    private String endTime;

    /**
     * 拼团状态
     * 0、未开团（未支付）
     * 1、拼团中
     * 2、拼团成功
     * 3、拼团失败
     */
    private int status;

    /**
     * SKU
     */
    @OneToOne
    private GoodsSku sku;

    /**
     * 商品编号
     */
    private String productNo;

    /**
     * 商品缩略图
     */
    private String defaultImage;

    /**
     * 商品名称
     */
    private String goodsName;

    /**
     * 成团人数
     */
    private int groupBookingCondition;

    /**
     * 拼团人数
     */
    private int groupBookingTotal;


    /**
     * 拼团成员订单
     */
    @OneToMany(fetch = FetchType.EAGER)
    @JoinColumn(name = "groupBooking_id", nullable = true)
    private List<GroupBookingOrder> details = Lists.newArrayList();

    @Transient
    private long systemTime;

    @Transient
    private List<Map<String, Object>> groupBookinges;

    @Transient
    private long goodsId;


}
